package com.zan.pattern.flyweight;

/**
 * @Author Zan
 * @Create 2024/4/26 18:06
 * @Description : TODO(请用一句话描述该类的功能)
 * @ClassName: Client
 */
public class Client {
    public static void main(String[] args) {
        // 获取I图形对象
        AbstractBox box1 = BoxFactory.getInstance().getShape("I");
        box1.display("蓝色");

        // 获取L图形对象
        AbstractBox box2 = BoxFactory.getInstance().getShape("L");
        box2.display("红色");

        // 获取O图形对象
        AbstractBox box3 = BoxFactory.getInstance().getShape("O");
        box3.display("绿色");

        // 获取O图形对象
        AbstractBox box4 = BoxFactory.getInstance().getShape("O");
        box4.display("灰色");

        System.out.println("两次获取到的O图形对象是否是同一个对象：" + (box3 == box4));
    }
}
